<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="author" content="m.jd.com">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/base2013.css" charset="gbk" />
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/my.css?r=2" charset="gbk" />
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/header.css" charset="gbk" />
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/js/self.js?r=2"></script>
    <style type="text/css">
        .padding_top{padding-top: 11px;}
        .orderStatistics{height:12.5px !important;}
    </style>
    <title>Title</title>
</head>
<body>
<header>
    <!-- 通用头 div -->
    <div id="m_common_header" style="min-height: 45px; margin-top: 0px;">
        <header class="jd-header">
            <div class="jd-header-bar">
                <div id="m_common_header_goback" class="jd-header-icon-back J_ping" onclick="javascript:window.location.href='/pages/wx/index.jsp';">
                    <span></span>
                </div>
                <div class="jd-header-title" style="max-width: 640px;margin: 0 auto">
                    个人中心
                </div>
            </div>
        </header>
    </div>
</header>
<a name="top"></a>
<div class="common-wrapper">

    <div class="myJD-content">
        <div class="product-title" style=" background: #fff;padding: 10px; border-radius: 10px" >
            <div style="width:40%;float:left;background-color: #fff;border-radius:15px;padding: 8px 10px;">
                <img name="headImage" class="customer" style="width:100%;" >
            </div>
            <div style="width:56%;float: left;margin-left:4%;">
                <div>
                    <label>姓名：</label><span name="name" class="customer" ></span>
                </div>
                <div>
                    <label>电话：</label><span name="telephone" class="customer"></span>
                </div>
                <div >
                    <label>客户级别</label>
                    <select name="customerLevelId" style="height: 40px;" >

                    </select>
                </div>

            </div>
            <div style="clear: both;">

            </div>
            <div align="center" style="margin-top: 30px;">
                <a style="background:#12B9DB;width: 200px;height: 40px;padding: 10px;border-radius: 5px;"
                   href="javascript:void(0)" onclick="save()">提交</a>
            </div>

        </div>

    </div>


</div>
</body>
<script type="text/javascript">
    $(function () {

        loadData();
    });
    function loadData() {
        var scrId =  getUrlParam("id");
        $.ajax({
            url:"/wap/supplier/customer/queryForSCLREdit.do",
            data:{'id':scrId},
            type:'post',
            dataType:'json',
            success:function(data){
                console.log(data);
                if(data.success){
                    if(!isNullOrUndefined(data.data)){
                        var customer =  data.data.customer;
                        var sclr = data.data.sclr;
                        var  customerLevels = data.data.customerLevels;
                        $("[name='headImage']").attr("src",customer.headImage);
                        $("[name='name']").html(customer.name);
                        $("[name='telephone']").html(customer.telephone);
                    }
                    initSelect("[name='customerLevelId']",customerLevels,"id","name");
                    $("[name='customerLevelId']").val(sclr.customerLevelId);
                }
            }
        });
    }
    function save() {
        var params = {};
        var scrId =  getUrlParam("id");
        params["id"] = scrId;
        params["customerLevelId"] =  $("[name='customerLevelId']").val();
        $.ajax({
            url: "/wap/supplier/customer/save.do",
            data: params,
            dataType: 'json',
            type: 'post',
            success: function (data) {
                console.log(data);
                if (data.success) {
                    alert("保存成功");
                    pageGoto("my_customer_list.html");
                } else {
                    alert(data.msg);
                }
            }
        });
    }
</script>
</html>